<template>
<div class="Box">
    <div class="imgBox">
        <img :src="props.pic" @click="goVideo"/>
        <p>
            <span>
                <img src="@/assets/searchIcon/play.png" />
                {{ formatNum( Number(props.play) ) }}
            </span>
            <span>
                {{ formatStrVideoTime(props.duration) }}
            </span>
        </p>
        <span class="txtShadow"></span>
    </div>
    <div class="infoBox">
        <span @click="goVideo">{{ props.title }}</span>
        <span>{{ formatMD(props.pubdate) }}</span>
    </div>

</div> 
</template>

<script lang="ts" setup>
import { formatNum,formatMD,formatStrVideoTime } from '@/utils/format'
import { useRouter } from 'vue-router'
interface Props{
    aid:number
    mid:number
    bvid:string
    duration:string
    pic:string
    pubdate:number      //创建时间戳
    play:string         //播放量
    title:string
}
const props = defineProps<Props>()
const router = useRouter()
function goVideo(){
    let routeData = router.resolve({path:'/video',query:{'avid':props.aid,'bvid':props.bvid,'cid':props.mid}})
    window.open(routeData.href, '_blank');
}
</script>

<style lang="scss" scoped>
p{
    padding: 0;
    margin: 0;
}
.Box{
    width: 100%;
    height: 100%;
}
.imgBox{
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 65%;
    & img:nth-child(1){
        width: 100%;
        height: 100%;
        border-radius: 4px;
        cursor: pointer;
    }
    & p:nth-child(2){
        padding:0 10px;
        box-sizing: border-box;
        position: absolute;
        bottom: 5px;
        left: 0;
        width: 100%;
        font-size: 13px;
        z-index: 9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: white;
    }
    & p:nth-child(2) span:nth-child(1){
        display: flex;
        justify-content: start;
        align-items: center;
        gap: 3px;
    }
    & p:nth-child(2) span:nth-child(1) img{
        margin-bottom: 2px;
        width:15px;
        height:14px;
    }
}
.txtShadow{
    position: absolute;
    width: 100%;
    left: 0;
    bottom: 0;
    height: 30px;
    background: linear-gradient(rgb(255, 255, 255,0) 0,rgb(0, 0, 0,0.8));
    border-radius: 4px;
}
.infoBox{
    height: 35%;
    padding-top: 10px;
    box-sizing: border-box;
    width: 100%;
    height: 35%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    & span:nth-child(1){
        line-height: 16px;
        font-size: 14px;
        color: #18191C;
        @include tweLineShow;
        height: 32px;
        text-align: left;
        cursor: pointer;
    }
    & span:nth-child(1):hover{
        color:#409EFF;
    }
    & span:nth-child(2){
        display: flex;
        justify-content: start;
        align-items: center;
        color: #9499A0;
        font-size: 13px;
        white-space: nowrap;
        cursor: default;
    }
}
</style>